﻿using Enum.ActionResult;

namespace Common
{
    public class ApiResult<Entity>  
    {
        public Status Status { get; set; }   

        public string? Message { get; set; } 

        public int StatusCode { get; set; }

        public bool IsSuccess { get; set; }

        public Entity? Data { get; set; }    

        public ApiResult<Entity> Success(Entity entity,string message = "成功")
        {
            return new ApiResult<Entity>
            {
                Status = Status.Success,
                Message = "成功",
                StatusCode = (int)Status.Success,
                Data = entity,
                IsSuccess = true
            };
        }

        public ApiResult<Entity> Error(Entity entity, string message = "成功")
        {
            return new ApiResult<Entity>
            {
                Status = Status.Error,
                Message = "失败",
                StatusCode = (int)Status.Error,
                Data = entity,
                IsSuccess = false
            };
        }
    }
}
